//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>
package org.jpgolay.wi.diary;

import java.awt.BorderLayout;
import javax.swing.*;
import org.jpgolay.gui.fixed.*;
import org.jpgolay.gui.iconBar.IconBar;

// Referenced classes of package org.jpgolay.wi.diary:
//            DiaryDetailsPanelGUI
public class DiaryGUI extends JInternalFrame {

    public DiaryGUI() {
        jContentPane = null;
        basicMenu = null;
        iconBar = null;
        mainSplitPane = null;
        diaryPanel = null;
        dataSplitPane = null;
        customerPanel = null;
        realEstatePanel = null;
        customerSearch = null;
        customerTable = null;
        realEstateSearch = null;
        realEstateTable = null;
        diaryTable = null;
        diaryDetailsPanelGUI = null;
        initialize();
    }

    private void initialize() {
        setJMenuBar(getBasicMenu());
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/sch.png")));
        setTitle("Agenda des r\351servations");
        setSize(514, 292);
        setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getIconBar(), "North");
            jContentPane.add(getMainSplitPane(), "Center");
        }
        return jContentPane;
    }

    private BasicMenu getBasicMenu() {
        if (basicMenu == null) {
            basicMenu = new BasicMenu();
        }
        return basicMenu;
    }

    private IconBar getIconBar() {
        if (iconBar == null) {
            iconBar = new IconBar();
        }
        return iconBar;
    }

    private JSplitPane getMainSplitPane() {
        if (mainSplitPane == null) {
            mainSplitPane = new JSplitPane();
            mainSplitPane.setLeftComponent(getDiaryPanel());
            mainSplitPane.setDividerSize(6);
            mainSplitPane.setDividerLocation(630);
            mainSplitPane.setOneTouchExpandable(true);
            mainSplitPane.setRightComponent(getDataSplitPane());
            mainSplitPane.setResizeWeight(0.0D);
        }
        return mainSplitPane;
    }

    private JPanel getDiaryPanel() {
        if (diaryPanel == null) {
            diaryPanel = new JPanel();
            diaryPanel.setLayout(new BorderLayout());
            diaryPanel.add(getDiaryTable(), "Center");
            diaryPanel.add(getDiaryDetailsPanelGUI(), "North");
        }
        return diaryPanel;
    }

    private JSplitPane getDataSplitPane() {
        if (dataSplitPane == null) {
            dataSplitPane = new JSplitPane();
            dataSplitPane.setDividerSize(8);
            dataSplitPane.setDividerLocation(180);
            dataSplitPane.setOneTouchExpandable(true);
            dataSplitPane.setOrientation(0);
            dataSplitPane.setTopComponent(getCustomerPanel());
            dataSplitPane.setBottomComponent(getRealEstatePanel());
        }
        return dataSplitPane;
    }

    private JPanel getCustomerPanel() {
        if (customerPanel == null) {
            customerPanel = new JPanel();
            customerPanel.setLayout(new BorderLayout());
            customerPanel.add(getCustomerSearch(), "North");
            customerPanel.add(getCustomerTable(), "Center");
        }
        return customerPanel;
    }

    private JPanel getRealEstatePanel() {
        if (realEstatePanel == null) {
            realEstatePanel = new JPanel();
            realEstatePanel.setLayout(new BorderLayout());
            realEstatePanel.add(getRealEstateSearch(), "North");
            realEstatePanel.add(getRealEstateTable(), "Center");
        }
        return realEstatePanel;
    }

    private SearchBox getCustomerSearch() {
        if (customerSearch == null) {
            customerSearch = new SearchBox();
            customerSearch.setNotAdvanceSearch(true);
            customerSearch.setPreferredSize(customerSearch.getSize());
            customerSearch.getButtonLeft().setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/wi/images/customerList16x16.png")));
            customerSearch.getButtonLeft().setToolTipText("Liste des clients");
        }
        return customerSearch;
    }

    private TableViewer getCustomerTable() {
        if (customerTable == null) {
            customerTable = new TableViewer();
        }
        return customerTable;
    }

    private SearchBox getRealEstateSearch() {
        if (realEstateSearch == null) {
            realEstateSearch = new SearchBox();
            realEstateSearch.setPreferredSize(realEstateSearch.getSize());
            realEstateSearch.setNotAdvanceSearch(true);
            realEstateSearch.getButtonLeft().setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/wi/images/logo.gif")));
            realEstateSearch.getButtonLeft().setToolTipText("Liste des biens");
        }
        return realEstateSearch;
    }

    private TableViewer getRealEstateTable() {
        if (realEstateTable == null) {
            realEstateTable = new TableViewer();
        }
        return realEstateTable;
    }

    private TableViewer getDiaryTable() {
        if (diaryTable == null) {
            diaryTable = new TableViewer();
        }
        return diaryTable;
    }

    private DiaryDetailsPanelGUI getDiaryDetailsPanelGUI() {
        if (diaryDetailsPanelGUI == null) {
            diaryDetailsPanelGUI = new DiaryDetailsPanelGUI();
        }
        return diaryDetailsPanelGUI;
    }

    public DiaryDetailsPanelGUI getDiaryDetailsPanel() {
        return getDiaryDetailsPanelGUI();
    }

    public SearchBox getCustomerSearchBox() {
        return getCustomerSearch();
    }

    public SearchBox getRealEstateSearchBox() {
        return getRealEstateSearch();
    }

    public TableViewer getCustomerTableViewer() {
        return getCustomerTable();
    }

    public TableViewer getRealEstateTableViewer() {
        return getRealEstateTable();
    }

    public TableViewer getDiaryTableViewer() {
        return getDiaryTable();
    }

    public BasicMenu getMenuPanel() {
        return getBasicMenu();
    }

    public IconBar getIconBarPanel() {
        return getIconBar();
    }

    public void cleanField() {
    }

    public void setEnabledField(boolean flag) {
    }
    private JPanel jContentPane;
    private BasicMenu basicMenu;
    private IconBar iconBar;
    private JSplitPane mainSplitPane;
    private JPanel diaryPanel;
    private JSplitPane dataSplitPane;
    private JPanel customerPanel;
    private JPanel realEstatePanel;
    private SearchBox customerSearch;
    private TableViewer customerTable;
    private SearchBox realEstateSearch;
    private TableViewer realEstateTable;
    private TableViewer diaryTable;
    private DiaryDetailsPanelGUI diaryDetailsPanelGUI;
}
